
#include "Bsp.h"
#include "WatchDog.h"

void WatchDog_Start(uint32_t time){
	uint32_t reload_value = time * 10 / 16;
	
    rcu_osci_on(RCU_IRC40K);
    /* wait till IRC40K is ready */
    while(SUCCESS != rcu_osci_stab_wait(RCU_IRC40K)){
    }  
    /* confiure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
    fwdgt_config(reload_value, FWDGT_PSC_DIV64);  
    /* after 1.6 seconds to generate a reset */
    fwdgt_enable();
}

void WatchDog_Reset(void){
	fwdgt_counter_reload();
}


